<?php 
namespace xfyzf\api\controller;
use xfyzf\api\controller\payconf;
use xfyzf\api\controller\epaysdk;
class Examine{
    /**
     * 检查订单信息是否合法
     * 
     * @param array|null $postdata 订单数据
     * @param array $userrow 商户信息
     * @return void
     */
    public static function examine(?array $postdata = null, array $userrow ,$send=false): void {
        global $conf, $date;
        
        $postdata['type'] = ($postdata['type'] == 'usdtpay') ? 'usdt' : $postdata['type'];
         
        // 错误消息
        $errorMsgs = [
            'type' => '支付方式不可为空！',
            'out_trade_no' => '订单号(out_trade_no)不能为空',
            'notify_url' => '通知地址(notify_url)不能为空',
            'return_url' => '回调地址(return_url)不能为空',
            'name' => '商品名称(name)不能为空',
            'money' => '金额(money)不能为空',
            'max_money' => '最大支付金额是' . $conf['pay_maxmoney'] . '元',
            'min_money' => '最小支付金额是' . $conf['pay_minmoney'] . '元',
            'invalid_money' => '金额不合法',
            'invalid_out_trade_no' => '订单号(out_trade_no)格式不正确',
            'insufficient_balance' => '当前商户额度不足[' . $postdata['money'] . ']，所以无法生成此订单,请商户们自行进行充值',
            'member_not_found' => '当前商户未开通此通道会员，所以无法生成此订单,请商户们自行进商户中心开通',
            'invalid_sign' => '支付签名错误！',
        ];
    
        // 检查必要参数
        foreach (['type', 'out_trade_no', 'notify_url', 'return_url', 'name', 'money'] as $field) {
            if (empty($postdata[$field])) sysmsg($errorMsgs[$field],$send);
        }
    
        // 检查金额范围
        if ($conf['pay_maxmoney'] > 0 && $postdata['money'] > $conf['pay_maxmoney']) sysmsg($errorMsgs['max_money'],$send);
        if ($conf['pay_minmoney'] > 0 && $postdata['money'] < $conf['pay_minmoney']) sysmsg($errorMsgs['min_money'],$send);
        if ($postdata['money'] <= 0 || !is_numeric($postdata['money'])) sysmsg($errorMsgs['invalid_money'],$send);
    
        // 检查订单号格式
        if (!preg_match('/^[a-zA-Z0-9.\_\-]+$/', $postdata['out_trade_no'])) sysmsg($errorMsgs['invalid_out_trade_no'],$send);
    
        // 检查商户余额
        if ($userrow['money'] < $postdata['money']) sysmsg($errorMsgs['insufficient_balance'],$send);
        $huiyuan = ($postdata['type'] == 'usdt') ? 'alipay' : $postdata['type'];
        // 检查会员状态
        $userrosc = strtotime($userrow[$huiyuan . '_free_vip_time']);
        $datemine = strtotime($date);
        $typeName = [
            'wxpay' => '微信',
            'qqpay' => 'QQ钱包',
            'alipay' => '支付宝',
            // 其他支付类型...
        ][$postdata['type']] ?? 'USDT（需要开通支付宝会员）';
        if ($userrosc < $datemine) sysmsg($errorMsgs['member_not_found'],$send);
    
        // 检查签名
        $config = ['pid' => $userrow['pid'], 'key' => $userrow['key']];
        $epay = (new EpayCore($config))->verifysubmit();
        if (!$epay && SubmitSign) sysmsg($errorMsgs['invalid_sign'],$send);
        $name = $postdata['name'];
        // 处理风险名单
        $domain = getdomain($postdata['notify_url']);
        if (!empty($conf['blockname'])) {
            $block_name = explode('|', $conf['blockname']);
            foreach ($block_name as $rows) {
                if (strpos($name, $rows) !== false) {
                    // 更新商户状态
                    $sql = "UPDATE `pay_user` SET `zt`='0' WHERE pid=:pid";
                    safeSqlQuery($sql, ['pid' => $postdata['pid']], 'update');
                    // 添加到风险名单
                    $sql = "INSERT INTO `pay_risk` (`pid`, `url`, `content`, `date`) VALUES (:pid, :url, :content, :date)";
                    safeSqlQuery($sql, ['pid' => $postdata['pid'], 'url' => $domain, 'content' => $rows, 'date' => $date], 'insert');
                    sysmsg($conf['blockalert']?$conf['blockalert']:'该商品禁止出售',$send);
                }
            }
        }
        $sql = "SELECT * FROM pay_order WHERE out_trade_no=:out_trade_no LIMIT 1";
        $params = ['out_trade_no' => $postdata['out_trade_no']];
        
        $result = safeSqlQuery($sql, $params)['result'][0]??'';
        if ($result) {
            sysmsg('商户订单号不能重复',$send);
        }
    }
    /**
     * 获取支付二维码行信息
     *
     * @param string $type 支付类型
     * @param array $userrow 用户信息
     * @param float $money 支付金额
     * @return array|null 返回支付二维码行信息，如果未找到则返回 null
     */
    public static function QR_row($type, $userrow, $money,$send=false) {
        global $DB;
    
        // 类型处理
        if ($type == 'usdt') $type = 'usdtpay';
    
        // 构建 SQL 查询
        $sql = "SELECT * FROM `pay_qrlist` WHERE `type`=:type AND `pid`=:pid AND `status`='1' ORDER BY nums ASC LIMIT 1";
        $params = ['type' => $type, 'pid' => $userrow['pid']];
        $QR_row = safeSqlQuery($sql, $params)['result'][0];
    
        // 根据类型进行额外的检查
        switch ($type) {
            case 'wxpay':
                if (!$QR_row) {
                    sysmsg('微信支付下单失败,暂无收款账户,或掉线',$send);  
                }
                break;
            case 'alipay':
                if (!$QR_row) {
                    sysmsg('支付宝支付下单失败,暂无收款账户,或掉线',$send);
                }
                break;
            case 'qqpay':
                if (!$QR_row) {
                    sysmsg('QQ钱包支付下单失败,暂无收款账户,或掉线',$send);
                }
                break;
            case 'usdtpay':
                if ($money < 1) {
                    sysmsg('USDT-TRC20下单失败,人民币金额必须大于一元',$send);
                }
                if (!$QR_row) {
                    sysmsg('USDT-TRC20下单失败,暂无收款账户',$send);
                }
                break;
        }
    
        // 更新 QR_row 的 nums 字段
        $sqlUpdate = "UPDATE `pay_qrlist` SET `nums` = `nums` + '1' WHERE `id` = :id";
        
        $paramsUpdate = ['id' => $QR_row['id']];
        $QR_rowa = safeSqlQuery($sqlUpdate, $paramsUpdate, 'update');
       
        // 检查是否需要重置 nums 字段为 0
        $sqlIs = "SELECT * FROM `pay_qrlist` WHERE `status`='1' and `type`=:type and `pid`=:pid and `nums`>'10' order by nums asc limit 1";
        $paramsIs = ['type' => $type, 'pid' => $userrow['pid']];
        $QR_is = safeSqlQuery($sqlIs, $paramsIs)['result'][0] ?? '';
        if ($QR_row && $QR_is) {
            if ($QR_row['id'] == $QR_is['id']) {
                $sqlReset = "UPDATE `pay_qrlist` SET `nums`='0' WHERE `type`=:type AND `pid`=:pid";
                $paramsReset = ['type' => $type, 'pid' => $userrow['pid']];
                safeSqlQuery($sqlReset, $paramsReset, 'update');
            }
        }
        return $QR_row;
    }
    /**
     * 计算订单金额并处理重复订单金额的情况
     *
     * @param string $type 订单类型
     * @param array $postdata 订单数据
     * @return float 计算后的订单金额
     */
    public static function amount($type, $postdata) {
        global $time, $QR_row;
    
        // 类型处理
        if ($type == 'usdt') $type = 'usdtpay';
        $money = $postdata['money'];
        // 初始化价格
        $price = ($type == 'usdtpay') ? usdt($type, $money) : $money;
        
        // 如果订单类型是 USDT 支付，则设置订单过期时间为当前时间戳 + 1200 秒
    
        // 构建查询 SQL
        $sql = "SELECT * FROM pay_order WHERE price=:price AND outtime > :time AND pid=:pid AND status='0'  AND type = :type LIMIT 1";
        $params = [
            'price' => $price,
            'time' => $time,
            'pid' => $postdata['pid'],
            'type' => $type
        ];
        $res = safeSqlQuery($sql, $params)['result'][0]??'';
    
        // 如果存在相同订单
        if ($res) {
            // 构建查询 SQL
            $sql = "SELECT * FROM pay_order WHERE price=:price AND outtime > :time AND pid=:pid AND status='0' LIMIT 1";
            $params = [
                'price' => $price,
                'time' => $time,
                'pid' => $postdata['pid']
            ];
            $rs = safeSqlQuery($sql, $params)['result'][0]??'';
            
            // 如果不存在相同订单，则保留原价格
            if (!$rs) {
                $price = $price;
            } else {
                $num = 1;
                for ($x = 0; $x <= $num; $x++) {
                    // 每次增加0.01，并构建查询 SQL
                    $price += 0.01;
                    $sql = "SELECT * FROM pay_order WHERE price=:price AND outtime > :time AND pid=:pid AND status='0' LIMIT 1";
                    $params = [
                        'price' => $price,
                        'time' => $time,
                        'pid' => $postdata['pid']
                    ];
                    $rs = safeSqlQuery($sql, $params)['result'][0]??'';
                    
                    // 如果不存在相同订单，则保留当前价格，并跳出循环
                    if (!$rs) {
                        $price = $price;
                        $num = 0; // 跳出循环
                    } else {
                        $num++; // 继续循环匹配
                    }
                }
            }
        } else {
            // 如果不存在相同订单，则保留原价格
            $price = $price;
        }
        // 返回计算后的价格
        return $price;
    }
    
    /**
 * 生成微信支付二维码并保存到本地
 */
    public static function wxpayqr_url(){
        global $type, $trade_no, $QR_row, $xf_url, $price;
       
        // 检查是否为微信支付类型
        if($type != 'wxpay') return; // 不是微信支付类型，直接返回
        
        // 定义二维码保存路径
        $pach = ROOT . 'Submit/img/wximg/';
        $filename = $pach . $trade_no . '.png';
        
        // 根据 hook_type 和 xf_type 进行处理
        $zz_url = true; // 默认为true，表示需要通过接口生成二维码的标志位
        switch ($QR_row['hook_type']) {
            case '2': // 如果 hook_type 为2
                switch ($QR_row['xf_type']) {
                    case 1: // 微信个码
                        $wxapi = createWxApiInstance($QR_row);
                        $qrurl =$wxapi->WXF2FQrcode($QR_row['cookie'], $price, $trade_no);
                        $qrurl = json_decode($qrurl, true)['pay_url'];
                        // 构建访问接口的 URL
                        $url = $xf_url . '/api/?url=' . urlencode($qrurl);
                        break;
                    case 7: // 微信收款单通道(IMAC)
                        // 调用 wxmacgrskdqrurl 函数获取二维码图片的 base64 编码内容
                        $base64_image_content = wxmacgrskdqrurl($QR_row, $price, $trade_no);
                        // 将 base64 编码的图片内容保存为图片文件
                        $png = base64_image_content($base64_image_content, $pach, $trade_no);
                        $zz_url = false; // 不需要通过接口生成二维码
                        break;
                    default: // 其他情况，直接使用原始的二维码链接
                        $url = $xf_url . '/api/?url=' . urlencode($QR_row['qr_url']);
                        break;
                }
                break;
            default: // hook_type 不是2，直接使用原始的二维码链接
                $url = $xf_url . '/api/?url=' . urlencode($QR_row['qr_url']);
                break;
        }
        
        // 如果需要通过接口获取二维码图片，则访问接口并保存图片到本地
        if($zz_url){
            // 调用接口获取二维码图片的数据
            $dataimg = get_curl($url);
            if ($dataimg) {
                // 将获取的二维码图片数据保存为图片文件
                file_put_contents($filename, $dataimg);
            }else{
                // 接口访问失败时，提示服务器错误
                sysmsg("服务器错误!");  
            }
        }
    }
    /**
     * 创建订单并存储到数据库中
     *
     * @return mixed 执行插入操作的结果
     */
    public static function order() {
        global $queryArr, $trade_no, $type, $pid, $date, $QR_row, $price, $ip, $userrow, $conf;
    
        // 减少并发递增金额
        $api_type = $pid;
        $api_type = daddslashes(substr(md5(urlencode($_SERVER['HTTP_HOST'] . '_' . $api_type)), 8, 10)) . '_' . $type;
    
        // 超过此时间则放弃此二维码
        $apitime = time() + 10;
    
        // 订单过期时间设定
        $outtime = isset($userrow['outtime']) ? $userrow['outtime'] : $conf['outtime'];
        $outtime = ($outtime > 180) ? $outtime : 180;
        $outtime = time() + (($outtime > 600) ? 600 : $outtime);
    
        // 类型处理
        if ($type == 'usdt') $type = 'usdtpay';
    
        // 如果订单类型是 USDT 支付，则设置订单过期时间为当前时间戳 + 1200 秒
        $outtime = ($type == 'usdtpay') ? time() + 1200 : $outtime;
    
        // 构建 SQL 插入语句
        $sql = "INSERT INTO `pay_order` (`trade_no`, `out_trade_no`, `notify_url`, `return_url`, `type`, `pid`, `addtime`, `name`, `money`, `qr_id`, `price`, `pay_id`, `api_type`, `apitime`, `outtime`, `status`) VALUES (:trade_no, :out_trade_no, :notify_url, :return_url, :type, :pid, :addtime, :name, :money, :qr_id, :price, :pay_id, :api_type, :apitime, :outtime, '0')";
        $params = [
            'trade_no' => $trade_no,
            'out_trade_no' => $queryArr['out_trade_no'],
            'notify_url' => $queryArr['notify_url'],
            'return_url' => $queryArr['return_url'],
            'type' => $type,
            'pid' => $pid,
            'addtime' => $date,
            'name' => $queryArr['name'],
            'money' => $queryArr['money'],
            'qr_id' => $QR_row['id'],
            'price' => $price,
            'pay_id' => $ip,
            'api_type' => $api_type,
            'apitime' => $apitime,
            'outtime' => $outtime
        ];
        
        // 执行 SQL 插入操作并返回结果
        return safeSqlQuery($sql, $params, 'insert');
    }
    
    public static function UserRegexamine($postdata=null){
        global  $conf;
        
        // 从$postdata中获取数据
        $email = $postdata['email'] ?? '';
        $user = $postdata['user'] ?? '';
        $qq = $postdata['qq'] ?? '';
        $phone = $postdata['phone'] ?? '';
        $pass  = $postdata['pass'] ?? '';
        // 邮箱格式验证
        if (!empty($email) && !filter_var($email, FILTER_VALIDATE_EMAIL)) {
            exitjson(500, "邮箱格式不正确");
        }
        
        // 用户名不包含中文字符验证
        if (!empty($user) && preg_match("/[\x{4e00}-\x{9fa5}]+/u", $user)) {
            exitjson(500, "用户名不能包含中文字符");
        }
        if(!empty($pass)){
            if(strlen($pass) < 6)exitjson(500, "密码长度不能少于6位");
            if(ctype_digit($pass))exitjson(500, "密码过于简单，请使用包含字母、数字和特殊字符的更复杂密码");
        }
        
        // 检查邮箱是否已注册
        if (!empty($email)) {
            $sql = "SELECT * FROM `pay_user` WHERE `email` = :email LIMIT 1";
            $params = ['email' => $email];
            $row = safeSqlQuery($sql, $params)['result'][0]??'';
            if ($row) {
                exitjson(-1, "该邮箱已经注册过商户，如需找回商户信息，请返回登录页面点击找回商户");
            }
        }
        
        // 检查用户名是否已注册
        if (!empty($user)) {
            $sql = "SELECT * FROM `pay_user` WHERE `user` = :user LIMIT 1";
            $params = ['user' => $user];
            $row = safeSqlQuery($sql, $params)['result'][0]??'';
            if ($row) {
                exitjson(-1, "该用户名已被平台用户注册过商户，如需找回账号信息，请点击找回商户");
            }
        }
        
        // 检查QQ是否已注册
        if (!empty($qq)) {
            $sql = "SELECT * FROM `pay_user` WHERE `qq` = :qq LIMIT 1";
            $params = ['qq' => $qq];
            $row = safeSqlQuery($sql, $params)['result'][0]??'';
            if ($row) {
                exitjson(-1, "该QQ已在平台注册过账号，如需找回账号信息，请点击找回商户");
            }
        }
        $to = $email;
        // 验证手机号
        if ($conf['verifytype'] == 'phone') {
            if (!empty($phone)) {
                $phone = preg_replace('/\D/', '', $phone);
                if (!preg_match('/^1[3-9]\d{9}$/', $phone)) {
                    exitjson(500, "手机号格式不正确");
                }
                
                // 检查手机号是否已注册或绑定
                $sql = "SELECT * FROM `pay_user` WHERE `phone` = :phone LIMIT 1";
                $params = ['phone' => $phone];
                $row = safeSqlQuery($sql, $params)['result'][0]??'';
                if ($row) {
                    exitjson(-1, "该手机号已在平台注册或绑定过账号，如需找回账号信息，请点击找回商户");
                }
                $to = $phone;
            }
        } else {
            $to = $email;
        }
        
        return $to;
    }
    
    public static function submit(){
        global  $type,$QR_row,$trade_no;
        if($type == 'alipay'){
            if($QR_row['cookie'] == 'xfqymckxy'){
                exit("<script>window.location.href='Submit/qymck?trade_no={$trade_no}';</script>");    
            }else if($QR_row['cookie'] == 'xfqydmfxy'){
                exit("<script>window.location.href='Submit/dmf?trade_no={$trade_no}';</script>");
            }else{
                exit("<script>window.location.href='Submit/Mcode_Pay?trade_no={$trade_no}';</script>");
            }
        }else if($type == 'usdtpay'){
            exit("<script>window.location.href='Submit/Usdt?trade_no={$trade_no}';</script>");
        }else{
            exit("<script>window.location.href='Submit/Mcode_Pay?trade_no={$trade_no}';</script>");
        }
        
    }
    
    public static function uservip($type){
        global $userrow,$date;
        $typeName = strip_tags(pay_type($type));
        $usdt    = ($type == 'usdtpay')?'(开通支付宝会员)':'';
        $huiyuan = ($type == 'usdtpay') ? 'alipay' : $type;
        $userrosc = strtotime($userrow[$huiyuan . '_free_vip_time']);
        $datemine = strtotime($date);
        
        if ($userrosc < $datemine) exitjson(-1,'您暂未开通'.$typeName.$usdt.'会员 请开通后在试！');
    }
    public static function usernum($hook_type = false){
        global $userrow,$user_pid,$conf;
        if(!$hook_type){
            $sql = "SELECT count(*) as count from pay_qrlist WHERE `pid`='{$user_pid}'";
            $num = executeSQLQuery($sql)['count'];
            $n   = $conf['qr_nums']?$conf['qr_nums']:$userrow['qr_nums'];
            if($num>$n)exitjson(-1,'您的配额已上限，请购买配额再次上传！');
        }
    }
    public static function cronkey($key){
        global $conf;
        if($key!==$conf['cronkey'])exit("您的KEY有误请核对后在试");
    }
    /**
     * 根据 xf_type 返回设备类型
     * 
     * @param string $xf_type 设备类型
     * @return string 返回设备类型：Mac 或 Windows
     */
    public static function sebei($xf_type){
        // 判断 xf_type 类型，返回对应的设备类型
        return ($xf_type == '1' || $xf_type == '7' || $xf_type == '8' || $xf_type == '9' || $xf_type == '10') ? 'Mac' : 'UOS';
    }
    public static function sdksign(){
        $pid = input("get")['pid'];
         $sql = "SELECT * FROM pay_user WHERE pid=:pid limit 1";
         $date = array(
            'pid'=>$pid
            );
        $userrow = safeSqlQuery($sql,$date)['result'][0]??'';
        if(!$userrow)sysmsg('非法操作');
        $xfpay_config = payconf::epay($userrow);
        $epay = new epaysdk($xfpay_config);
        if(!$epay->return_url()){
            sysmsg('签名效验失败！请勿修改数据哦~(*￣︶￣)~！');
        }
    }
    public static function usertokendecode($token){//用户中心token解密
        $token1= aes256auth($token,PCTOKENKEY,"DECODE");
        
        if(!$token1)return false;
        $json = json_decode($token1,true);
        
        if(!$json)return false;
        $pid=$json['pid'];
        $key = $json['key'];
        
        $sql = "SELECT * FROM pay_user WHERE `pid`=:pid and `key`=:key limit 1";
        $paramsSelect = [
            'pid' => $pid,
            'key'=> $key
        ];
        $userrow = safeSqlQuery($sql, $paramsSelect)['result'][0];
        if($userrow){
            return array(
                   "pid"=>$pid,
                   "key"=>$key
               );
        }
        return false;
    }
    public static function userrow($pid){
        $sql = "SELECT * FROM pay_user WHERE  `pid` = :pid LIMIT 1";
        $paramsSelect = [
            'pid' => $pid
        ];
        
        return safeSqlQuery($sql, $paramsSelect)['result'][0]??'';
    }
    public static function exitWithMessage($code, $message, $extra = null) {
        $response = array('code' => $code, 'msg' => $message);
        if ($extra !== null) {
            $response = array_merge($response, $extra);
        }
        exit(json_encode($response));
    }
    public static function exitjson($code, $message, $extra = null) {
        $response = array('code' => $code, 'msg' => $message);
        if ($extra !== null) {
            $response = array_merge($response, $extra);
        }
        exit(json_encode($response));
    }
    public static function checkRequiredParams($params , $send = false) {
        foreach ($params as $param) {
            if (empty($param)) {
                if($send) return true;
                exitjson(-1, '所有内容不可为空');
            }
        }
        return false;
    }
    public static function mapiqrcode($QR_row , $trade_no , $userrow ,  $price = ''){
         global  $httphost,$xf_url;
        $qrcode = '';
        $code_url = '';
        $xf_moshi = $userrow['INPUTFREE'];
        switch ($QR_row['type']){
            case 'alipay':
                if($QR_row['hook_type'] == 0 ){
                    if($QR_row['cookie'] !='xfqydmfxy' && $QR_row['cookie'] !='xfqymckxy'){
                         $userId = getSubstr(base64_decode($QR_row['cookie']), "CLUB_ALIPAY_COM=", ";");
                         $qrcode = aliqrurl($userId,$trade_no,$price,$xf_moshi);
                    }else if($QR_row['cookie'] =='xfqymckxy'){
                          $userId = $QR_row['alipayUId'];
                          $qrcode = aliqrurl($userId,$trade_no,$price,$xf_moshi);
                    }
                   
                }else if($QR_row['hook_type'] == 1){
                    $userId = getSubstr(base64_decode($QR_row['cookie']), "CLUB_ALIPAY_COM=", ";");
                    $qrcode = aliqrurl($userId,$trade_no,$price,$xf_moshi);
                }else if($QR_row['hook_type']  == 3){
                    $qrcode = $QR_row['qr_url'];
                }
                break;
            case 'wxpay':
                if(($QR_row['hook_type'] == 0 || $QR_row['hook_type'] == 1)){
                    if($QR_row['xf_type']=='5' || $QR_row['xf_type']=='4'){
                        $code_url = $QR_row['qr_url'];
                    }else{
                        $qrcode = $QR_row['qr_url'];
                    }
                }else if($QR_row['hook_type'] == 2){
                    if($QR_row['xf_type'] == '1'){
                        $qrcode = wxgmqrurl($QR_row,$price,$trade_no);
                    }else if($QR_row['xf_type'] == '2' || $QR_row['xf_type'] == '7'){
                        $code_url = $httphost.'/Submit/img/wximg/'.$trade_no.'.png';
                    }else if($QR_row['xf_type']  == '3'){
                        $qrcode = wxgmbmsqrurl($QR_row['cookie']);
                    }else if($QR_row['xf_type']  == '4'  || $QR_row['xf_type'] == '8'){
                        $code_url = $QR_row['qr_url'];
                    }else if($QR_row['xf_type']  == '5' || $QR_row['xf_type']  == '9' || $QR_row['xf_type']  == '6' || $QR_row['xf_type']  == '10' ){
                        $qrcode = $QR_row['qr_url'];
                    }
                }else if($QR_row['hook_type'] == 3){
                     $qrcode = $QR_row['qr_url'];
                }
                break;
            case 'qqpay':
                $xf_qr_row=get_curl($xf_url."/api/qqms.php?money=".$price."&beizhu=".$trade_no."&cookie=".$QR_row['cookie']."&url=".$_SERVER['HTTP_HOST']);
                $qrcode = $xf_qr_row;
                break;
        }
        return array(
            'qrcode' =>$qrcode,
            'code_url' =>$code_url
            );
    }
}

?>